<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>角色视图</title>
</head>
<body class="skin-default">

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <!--视图块-->
            <div class="container-fluid card">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--检索栏-->
                        <form class="form-inline search-bar" id="pageForm">
                            <div class="form-group">
                                <label class="control-label">角色编号：&nbsp;</label>
                                <input type="text" name="id" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">角色名称：&nbsp;</label>
                                <input type="text" name="name" class="form-control">
                            </div>
                            <!--<div class="form-group">
                                <label class="control-label">管理范围：&nbsp;</label>
                                <input type="text" name="rangeId" class="form-control">
                            </div>-->
                            <div class="form-group">
                                <label class="control-label">角色类型：&nbsp;</label>
                                <select name="type" class="form-control">
                                    <option value=""></option>
                                    <option value="1">管理角色</option>
                                    <option value="2">普通角色</option>
                                </select>
                            </div>
                            <!--<div class="form-group">
                                <label class="control-label">所属单位：&nbsp;</label>
                                <input type="text" name="companyId" class="form-control">
                            </div>-->
                            <!--<div class="form-group">
                                <label class="control-label">角色分类：&nbsp;</label>
                                <input type="text" name="category" class="form-control">
                            </div>-->
                            <div class="form-group">
                                <label class="control-label">向下公开：&nbsp;</label>
                                <select name="open" class="form-control">
                                    <option value=""></option>
                                    <option value="0">不公开</option>
                                    <option value="1">向直属下级单位公开</option>
                                    <option value="2">向所有下级单位公开</option>
                                    <option value="3">向部分下级单位公开</option>
                                </select>
                            </div>
                            <!--<div class="form-group">
                                <label class="control-label">创建人：&nbsp;</label>
                                <input type="text" name="createUserId" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">更新人：&nbsp;</label>
                                <input type="text" name="updateUserId" class="form-control">
                            </div>-->
                            <div class="form-group">
                                <label class="control-label">删除标识：&nbsp;</label>
                                <select name="trashFlag" class="form-control">
                                    <option value=""></option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                            <button type="button" class="btn btn-primary" onclick="joView.select()"> <i class="fa fa-search" aria-hidden="true"></i>&nbsp;查询</button>
                        </form>
                        <!--/检索栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--按钮栏-->
                        <div class="form-group button-bar">
                            <button isShow="" type="button" class="btn btn-primary" onclick="joView.add()">
                                <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;新增
                            </button>
                            <button type="button" class="btn btn-danger" onclick="joView.del()">
                                <i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;删除
                            </button>
                            <button type="button" class="btn btn-warning" onclick="window.location.reload()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                            </button>
                        </div>
                        <!--/按钮栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4 col-md-3 col-lg-3">
                        <ul class="ztree" id="companyTree"></ul>
                    </div>
                    <div class="col-sm-8 col-md-9 col-lg-9">
                        <div class="table-bar">
                            <!--grid-->
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover" id="mainList" dataUrl="{URL_UMS}ums/role/getPage" deleteUrl="{URL_UMS}ums/role/delete" formUrl="/page/ums/roleForm.html">
                                    <col field="name" title="角色名称" width="15%" align="" event="click" />
                                    <col field="typeShow" title="角色类型" width="10%" align=""  />
                                    <col field="companyName" title="所属单位" width="20%" align=""  />
                                    <col field="remark" title="描述" width="20%" align=""  />
                                    <!--<col field="rangeId" title="管理范围" width="10%" align=""  />-->
                                    <!--<col field="category" title="角色分类" width="10%" align=""  />-->
                                    <col field="open" title="向下公开" width="10%" align=""  />
                                    <col field="num" title="排序" width="10%" align=""  order="num"/>
                                </table>
                            </div>
                            <!--/grid-->

                            <!--分页条-->
                            <div class="page-bar" gridId="mainList">

                            </div>
                            <!--/分页条-->
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<style>
    html,body{
        height: 100%;
    }
</style>
<script type="text/javascript">
    //高度适配
    function heightAdapt(){
        var h = $('body').height() - $(".card>.row:eq(0)").outerHeight() - $(".card>.row:eq(1)").outerHeight() - 60;
        if(h > 300){//避免高度过于小
            $(".table-bar").css('height', h+'px').css('overflow', 'auto');
            $("#companyTree").css('height', h+'px').css('overflow', 'auto');
        }else{//默认高度为auto
            $(".table-bar").css('height', 'auto').css('overflow', 'auto');
            $("#companyTree").css('height', 'auto').css('overflow', 'auto');
        }
    }
    window.onresize = function(){
        heightAdapt();
    };
    heightAdapt();


    layui.laydate.render({
        elem: '#createTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#createTime2' //注册日期控件
    });
    layui.laydate.render({
        elem: '#updateTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#updateTime2' //注册日期控件
    });
    $(function(){
        createCompanyTree('companyTree', function(event, treeId, treeNode){
            joView.putQueryParam('companyId', treeNode.id);
            joView.select();//查询
        });
        joView.init({grid:$("#mainList"),PKName:"id"});//初始化页面
    });
    //表格渲染时行处理,参数1为当前行的数据对象,参数2为当前行的索引值(最小为0)
    joView.handleItem = function(oItem,iIndex){
        oItem.open = formatRoleOpen(oItem.open);
        oItem.typeShow = formatRoleType(oItem.type);
    };
    //表格渲染完成后的回调,参数为表格数据(数组对象)
    joView.setGridDataAfter = function(oList){

    };

    //格式化角色类型
    function formatRoleType(type){
        if(type == '1'){
            return '<span class="label label-primary">管理角色</span>';
        }else if(type == '2'){
            return '<span class="label label-warning">普通角色</span>';
        }else{
            return type;
        }
    }
    //格式化角色公开类型
    function formatRoleOpen(type){
        if(type == '0'){
            return '<span class="label label-primary">不公开</span>';
        }else if(type == '1'){
            return '<span class="label label-info">直属下级单位</span>';
        }else if(type == '2'){
            return '<span class="label label-success">所有下级单位</span>';
        }else if(type == '3'){
            return '<span class="label label-warning">部分下级单位</span>';
        }else{
            return type;
        }
    }

    /* 关于joView更多回调函数和配置参数可查看jo-page-view.js */
</script>
</body>
</html>
